#include "../LOGS/Logs.hpp"
#include <cassert>
#include <iostream>

// // Logs
void loggerTest(const std::string &logger_name) 
{
    Logs::Logger::Ptr lp = Logs::getLogger(logger_name);
    assert(lp.get());
    std::cout << "------------example--------------------" <<std::endl;
    lp->debug("%s", "logger->debug");
    lp->info("%s", "logger->info");
    lp->warn("%s", "logger->warn");
    lp->error("%s", "logger->error");
    lp->fatal("%s", "logger->fatal");
    // DEBUG(lp, "%s", "LOG_DEBUG");
    // INFO(lp, "%s", "LOG_INFO");
    // WARN(lp, "%s", "LOG_WARN");
    // ERROR(lp, "%s", "LOG_ERROR");
    // FATAL(lp, "%s", "LOG_FATAL");
    std::cout << "---------------------------------------" << std::endl;
    
    std::string log_msg = "hello bitejiuyeke-";
    size_t fsize = 0;
    size_t count = 0;
    while(count < 1000000) {
        std::string msg = log_msg + std::to_string(count++);
        lp->error("%s", msg.c_str());
    }
}
void functional_test() 
{
    Logs::GlobalLoggerBuilder::Ptr lbp(new Logs::GlobalLoggerBuilder());
    lbp->BuildLoggerName("all_sink_logger");
    lbp->BuildFormatter("[%d][%c][%f:%l][%p] %m%n");
    lbp->BuildLoggerLevel(Logs::Level::Value::DEBUG);
    lbp->BuildSink<Logs::StdoutSink>();
    lbp->BuildSink<Logs::FileSink>("./logs/sync.log");
    lbp->BuildSink<Logs::RollBySizeSink>("./logs/roll-", 10 * 1024 * 1024);
    lbp->BuildLoggerType(Logs::LoggerType::LOGGER_ASYNC);
    lbp->Build(); 
    loggerTest("all_sink_logger");
}
int main(int argc, char *argv[])
{
    functional_test();

    return 0;
}